<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>预约时间(经纪人)</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="${path}/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="${path}/css/TenantCentre.css">
    <link rel="stylesheet" href="${path}/css/home.css">
</head>
<style>
    .gray-bg{
        margin: 0;
        padding: 0;
        font-family: sans-serif;
        background: url(http://${path2}/img/agent.jpg)  no-repeat center 0px;
        background-size: cover;

        background-position: center 0;
        background-repeat: no-repeat;
        background-attachment: fixed;
        -webkit-background-size: cover;
        -o-background-size: cover;
        -moz-background-size: cover;
        -ms-background-size: cover;

    }
</style>
<body class="gray-bg">
<script src="${path}/plugins/jquery-3.4.1.js"></script>
<script src="${path}/plugins/bootstrap-3.3.7-dist/js/bootstrap.js"></script>

<%@include file="topB.jsp"%>



<div class="col-md-9 zy3" style="overflow:auto">
    <div style="height:1000px;width: 850px">
    <table class="table table-hover">
        <thead>
        <tr>
            <th>房源名/门牌号</th>
            <th>房东姓名</th>
            <th>房东电话</th>
            <th>租赁状态</th>
            <th>确认发布</th>
        </tr>
        </thead>
        <tbody id="tb">
        <c:forEach items="${houseList}" var="h" varStatus="loop">

            <tr>
                <td style="display: none">${landlordList[loop.count-1].id}</td>
                <td name="housename">${h.residentialQuarters}<br>门牌号:${h.doorplate}</td>
                <td>${landlordList[loop.count-1].name}</td>
                <td>${landlordList[loop.count-1].phone}</td>
                <td style="color: red;font-weight: bolder">${h.houseState}</td>
                <td><button type="button" class="btn btn-success" onclick="changetrue(this,${h.id})">确认</button>&nbsp;&nbsp;
                    <button type="button" class="btn btn-danger" onclick="changefalse(this,${h.id})">删除</button></td>
                <td style="display: none">${h.agentId}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    </div>
</div>


<%@include file="BottomB.jsp"%>

<script>
    function changetrue(obj,id) {
        let tr = obj.parentElement.parentElement;
        let td0 = $(tr).find('td').eq(0);
        let landlordId = td0[0].innerText;
        let td1 = $(tr).find('td').eq(1);
        let housename = td1[0].innerText;
        let datas = {"id":id,"housename":housename,"landlordId":landlordId};
        if(confirm("确定出租该房源?")) {
            $.post('/taofang/Verify/Sure', datas, function (data) {
                if (data.code == 200) {
                    tr.remove();
                } else {
                    alert("确认失败")
                }
            })
        }
    }


    function changefalse(obj,id) {
        let tr = obj.parentElement.parentElement;
        let td0 = $(tr).find('td').eq(0);
        let landlordId = td0[0].innerText;
        let td1 = $(tr).find('td').eq(1);
        let housename = td1[0].innerText;
        let td6 = $(tr).find('td').eq(6);
        let agentId = td6[0].innerText;
        let datas = {"id":id,"housename":housename,"landlordId":landlordId,"agentId":agentId};
        if(confirm("确定出租该房源?")) {
            $.post('/taofang/Verify/Cancel', datas, function (data) {
                if (data.code == 200) {
                    tr.remove();
                } else {
                    alert("取消失败")
                }
            })
        }

    }

</script>

</body>
</html>